09. Functions and Data Structures

08 Functions And Data Structures

Relational Operators Description
== Equal
!= Not Equal
> Greater
< Less
>= Greater or Equal
<= Less or Equal

1- Copy this code to your editor and save it on your VM Desktop as EvenNumbers.cpp:

#include <iostream>
using namespace std;

int my_array[11]={0,1,2,3,4,5,6,7,8,9,10};

void FindEven(int array[])
{
    for(int i=0; i<=10; i++)
    {
        if(array[i] % 2 == 0)
            cout << array[i]<<endl;
    }
}

int main() 
{
    FindEven(my_array);

    return 0;
} 

2- After copying the code, navigate to Desktop:

$ cd Desktop

3- Compile your code with g++:

$ g++ EvenNumbers.cpp -o app

4- Now, you can run the executable file:

$ ./app

5- Finally, after running the program, verify its output:

Loop Syntax

How many numbers will be printed after compiling and executing this program?

#include <iostream>
using namespace std;

int main() 
{
    for(int i=0; i<=5; i++)
    {
       cout << i << endl;
    }
}
SOLUTION: 6

Array Syntax/

Select the number that will be printed after compiling and executing this program?

#include <iostream>
using namespace std;

int main() 
{
    int my_array[]={1,2,3,4};
    cout << my_array[1];
}
SOLUTION: 2